<?php

class UploadCsvController extends BaseController {
	public function uploadCsv()
	{
		return View::make('uploadCsv');
	}

	public function doUpload() {
		// TODO Upload processing.
		// echo "<pre>";
		// print_r(Input::all());
		// echo "</pre>";

		// echo "<pre>";
		// print_r(Input::file("image"));
		// echo "</pre>";

		$uploadedImages = array();
		foreach(Input::file("image") as $image) {
			$imageName = time() . "_" . $image->getClientOriginalName();

			$uploadFlag = $image->move("uploads", $imageName);

			if($uploadFlag) {
				$uploadedImages[] = $imageName;
			}
		}

		return Response::json(array("success" => true, "message" => "Images uploaded", "images" => $uploadedImages));
	}

}
